﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;

namespace Wedo.IPRP.Web.Controllers
{
    public class CultrueController : Controller
    {
        /// <summary>
        /// 多语言Action
        /// </summary>
        /// <param name="culture">
        /// 要切换的语言,zh-cn...
        /// </param>
        public ActionResult SetCulture(string culture)
        {
            if (!string.IsNullOrEmpty(culture)) 
            {
                if (HttpContext.Request.Cookies["cultrue"] == null)
                {
                    HttpCookie cookie = new HttpCookie("cultrue");
                    cookie.Value = culture;
                    cookie.Expires = DateTime.Today.AddDays(30);
                    HttpContext.Response.Cookies.Add(cookie);
                }
                else
                {
                    HttpContext.Response.Cookies["culture"].Value = culture;
                }
            }
            if (Request.UrlReferrer != null)
                return Redirect(Request.UrlReferrer.ToString());
            else
                return Redirect("~/Home/Index");
        }
    }
}
